package file;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        //函数式接口:带有注解@FunctionalInterface的接口都是
        //FileFilter filter = p->p.getName().endsWith(".txt");
        File file = new File(".");
        File [] sub = file.listFiles(p->p.getName().endsWith("txt"));
        System.out.println("符合条件的有"+sub.length+"个");
        for (File a: sub) {
            System.out.println(a.getName());
        }

    }
}
